<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/21
 * Time: 10:26
 */
class 图片的二进制存取
{

}

$filename = "Admin/Upload/3025994.jpg";
// 读取文件
$fp = fopen($filename,"rb");
$data   =   addslashes(fread($fp,filesize($filename)));
fclose($fp);
// 操作MYSQL
$conn=mysql_connect("localhost","root","admin");
@mysql_select_db("mytest",$conn);
// 存入数据库
$query="insert into pic values (5,'$data')";
$result=mysql_query($query);
$id=mysql_insert_id();
//读取数据
$query="select * from pic where picid=5 limit 0,1";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$data = $row["Pic"];
// 显示文件
header("Content-type: image/*");
echo $data;